<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function getRandomInt(min, max) {
            return Math.floor(Math.random() * (max - min)) + min; //不含最大值，含最小值
        }
        var num2 = getRandomInt(1,50);
        for (i = 0; i <10; i++){
            
        var num = prompt('请猜猜我想的数字是什么');
        
        if ( num >num2 ) {
            alert('数字大了，继续猜');

        }else if(num <num2) {
            alert('数字小了，继续猜')
        
        }
        else if(num = num2){
            alert('恭喜你猜中了');
            break;
        }
    }
    </script>
</head>
<body>
    
</body>
</html>